package com.example.mycat.controller;


import com.example.mycat.model.User;
import com.example.mycat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 控制层去掉业务层
     * 把哪两个参数传进去
     * 由于在model里定义了ID策略是使用UUID，所以下面就不用传id这个参数了
     * @param username
     * @param password
     * @return
     */
    @GetMapping("save")
    public String saveUser(String username,String password){
       User user =  userService.saveUser(new User(username,password));
        if (user == null){
            return "保存失败";
        }else {
            return "保存成功";
        }
    }

}
